aboutsummaryrefslogtreecommitdiff
path: root/src/pages/blog/[...slug].astro
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages/blog/[...slug].astro')
-rw-r--r--src/pages/blog/[...slug].astro22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro
new file mode 100644
index 0000000..7db75bb
--- /dev/null
+++ b/src/pages/blog/[...slug].astro
@@ -0,0 +1,22 @@
+---
+import Page from '../../layouts/BlogPost.astro';
+import { getEntry } from 'astro:content';
+const { slug } = Astro.params;
+
+if (slug === undefined) {
+ throw new Error('Slug is required');
+}
+
+const entry = await getEntry('blog', slug);
+
+if(entry === undefined) {
+ return Astro.redirect('/404');
+}
+
+const { Content } = await entry.render();
+---
+<Page title={entry.data.title} description={entry.data.description}>
+ <main>
+ <Content />
+ </main>
+</Page>